package base.core.swagger;

import com.google.common.base.Optional;
import com.google.common.base.Predicate;

import springfox.documentation.RequestHandler;

/**
 * Pengwei
 * 2022/7/25 22:47
 */
public class SwaggerUtils {
    public static Predicate<RequestHandler> basePackage(final String basePackage) {
        return input -> Optional.fromNullable(input.declaringClass()).transform(input1 -> {
            /* 循环判断匹配*/
            for (String strPackage : basePackage.split(",")) {
                boolean isMatch = input1.getPackage().getName().startsWith(strPackage);
                if (isMatch) {
                    return true;
                }
            }
            return false;
        }).or(true);
    }
}
